package com.itheima.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.common.R;
import com.itheima.domain.Checkgroup;
import com.itheima.domain.Checkitem;
import com.itheima.service.CheckgroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/checkgroup")
public class CheckgroupController {
    @Autowired
    private CheckgroupService checkgroupService;
    @GetMapping("/page")
    public R<Page<Checkgroup>> getByPage(int currentPage, int pageSize, String name){
        //创建分页构造器
        Page<Checkgroup> pageInfo = new Page<>(currentPage,pageSize);

        //创建条件构造器
        LambdaQueryWrapper<Checkgroup> lqw = new LambdaQueryWrapper<>();
//
        if(name!=null){
            lqw.like(Checkgroup::getName,name);
        }

        //调用方法，获取数据
        checkgroupService.page(pageInfo,lqw);
        //返回数据
        return R.success(pageInfo);
    }
}
